package com.hfb.mashibing.alip8.juc.c020;


import java.util.concurrent.locks.LockSupport;

/**
 * 锁的底层支持类
 */

public class T13_TestLockSupport {
    public static void main(String[] args) {

        Thread t = new Thread(()->{
            for (int i=0;i<10;i++) {
                System.out.println(Thread.currentThread().getName()+" "+i);
                if (i == 5) {
                    LockSupport.park();
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"T1");

        t.start();

        try {
            Thread.sleep(8000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("after 2 s ");
        LockSupport.unpark(t);

    }
}
